luci-app-statistics: Adds ability to configure encrypted connections in the MQTT...
authorNat Gist <[email protected]>
Fri, 22 Aug 2025 20:44:02 +0000 (20:44 +0000)
committerHannu Nyman <[email protected]>
Mon, 25 Aug 2025 16:27:53 +0000 (19:27 +0300)
Updates mqtt.js to add user interface to configure a path to a CA Cert file to be used by MQTT to verify the servers certificate, and adds a setting to configure the TLS verison to be used for the conneciton. Also updates stat-genconfig to then copy these settings into the generated collectd.conf

Signed-off-by: Nat Gist <[email protected]>
applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js
applications/luci-app-statistics/root/usr/libexec/stat-genconfig

index 602a453c0b23d66ee1b8948598fbfe82941af9c6..73de2f5cf686a355cdbf3203f76f6ffb851ea081 100644 (file)
@@ -68,6 +68,19 @@ return baseclass.extend({
         o.value('false', _('False'));
         o.modalonly = true;
         o.optional = true;
+        
+        o = ss.option(form.ListValue, 'TLSProtocol', _('TLSProtocol'));
+        o.depends('blocktype', 'Publish');
+        o.value('tlsv1.2', _('TLS 1.2'));
+        o.value('tlsv1.3', _('TLS 1.3'));
+        o.modalonly = true;
+        o.optional = true;
+
+        o = ss.option(form.Value, 'CACert', _('CACert'));
+        o.depends({'TLSProtocol': 'tls', '!contains': true });
+        o.optional = true;
+        o.modalonly = true;
+        o.default = '/etc/ssl/certs/ca-certificates.crt';
 
         o = ss.option(form.ListValue, 'CleanSession', _('CleanSession'));
         o.depends('blocktype', 'Subscribe');
index 0d6bd6704f69a4812e60808e38e2ce568d62e39d..68c9b09e889356ce3e678f2789f608e270208d1e 100755 (executable)
@@ -260,6 +260,8 @@ function config_mqtt(c) {
                                        str += s['StoreRates'] ? `\t\tRetain ${s.StoreRates}\n` : '';
                                        str += s['CleanSession'] ? `\t\tRetain ${s.CleanSession}\n` : '';
                                        str += s['Topic'] ? `\t\tTopic "${s.Topic}"\n` : '';
+                                       str += s['CACert'] ? `\t\tCACert "${s.CACert}"\n` : '';
+                                       str += s['TLSProtocol'] ? `\t\tTLSProtocol "${s.TLSProtocol}"\n` : '';
 
                                        str += isPublish ? `\t</Publish>\n` : `\t</Subscribe>\n`;
                        }